package progress.exa31_1;

import java.util.Arrays;
import java.util.Comparator;

public class LambdaStudy {

    public static void main(String[] args) {

//        lambdaTest1();
        //ThreadLambda();
        lambdaTest2();

    }

    public static void ThreadLambda(){
        new Thread(()->{
            for(int i=100;i>=0;i--)
                System.out.println(i);
        }).start();
    }

    public static void lambdaTest1(){
        String[] strings = new String[4];
        strings[0] = "33123";
        strings[1] = "1";
        strings[2] = "813";
        strings[3] = "1823";
        Arrays.sort(strings,(String first,String second)->{
            if(first.length()<second.length())
                return -1;
            else if(first.length()>second.length())
                return 1;
            else return 0;
        });
        System.out.println(strings[0]);
    }

    public static void lambdaTest2(){
        Comparator<String> comp = (first, second) ->{
            if(first.length()<second.length())
                return -1;
            else if(first.length()>second.length())
                return 1;
            else return 0;
        };
        String[] strings = new String[4];
        strings[0] = "33123";
        strings[1] = "1";
        strings[2] = "813";
        strings[3] = "1823";
        Arrays.sort(strings,comp);
        System.out.println(strings[0]);
    }

    public static void lambdaTest3(){
        Comparator<String> comp = (first, second) ->{
            if(first.length()<second.length())
                return -1;
            else if(first.length()>second.length())
                return 1;
            return 0;
        };
    }



}
